﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp0
{
    public partial class Form22 : Form
    {
        string a1 = "";
        string b2 = "";
        string c3 = "";
        string d4 = "";
        string e5 = "";
        string f6 = "";
        string g7 = "";
        public Form22()
        {
            InitializeComponent();
        }
        public Form22(string id,string name,string unit,string norm ,string jin,string ding,string state)
        {
            InitializeComponent();
            a1=textBox1.Text = id;
            b2=textBox2.Text = name;
            c3=textBox3.Text = unit;
            d4=textBox4.Text = norm;
            e5=textBox5.Text = jin;
            f6=textBox6.Text = ding;
            g7=textBox7.Text = state;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = $"update Merchandise set Mid='{textBox1.Text}',Mname='{textBox2.Text}',Munit='{textBox3.Text}',Mnorm='{textBox4.Text}',Mpurchas='{textBox5.Text}',Mprince='{textBox6.Text}',Mstate='{textBox7.Text}'where Mid='{a1}'";
            Dao dao = new Dao();
            int n = dao.Execute(sql);
           
            if (n > 0)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = a1;
            textBox2.Text = b2;
            textBox3.Text = c3;
            textBox4.Text = d4;
            textBox5.Text = e5;
            textBox6.Text = f6;
           textBox7.Text = g7;
        }

        private void Form22_Load(object sender, EventArgs e)
        {

        }
    }
}
